package study.transaction.atomikos.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import study.transaction.atomikos.mapper.account.AccountBaseEO;
import study.transaction.atomikos.mapper.account.AccountBaseMapper;
import study.transaction.atomikos.mapper.user.UserBaseEO;
import study.transaction.atomikos.mapper.user.UserBaseMapper;

@Service
public class UserService {

    @Autowired
    private UserBaseMapper userBaseMapper;
    @Autowired
    private AccountBaseMapper accountBaseMapper;

    @Transactional
    public void create(boolean ex) {
        UserBaseEO ubEO = new UserBaseEO();
        ubEO.setUbLoginName("zerowzj");
        ubEO.setUbLoginPwd("123");
        userBaseMapper.insert(ubEO);


        AccountBaseEO abEO = new AccountBaseEO();
        abEO.setAbUbId(ubEO.getUbId());
        if (ex) {
            abEO.setTest(111L);
        }
        accountBaseMapper.insert(abEO);
    }
}
